import Taro from '@tarojs/taro'
import { View,Swiper,SwiperItem,Image } from '@tarojs/components'
import { useState,useEffect } from 'react'
import { showBanner } from '../../api/mode'
import './index.scss'

export default function NewsSwiper () { 
  // const auth=Taro.getStorageSync(`auth`);
  const [photoInfo,setPhotoInfo]=useState([])
  useEffect(
    ()=>{
        showBanner().then(
          res=>{
            // console.log(res.data.data);
          setPhotoInfo(res.data.data)      
          })

    },[]
  )
  
  return (
    <View className='newSwiper'>
            <Swiper
              className='test-h'
              indicatorColor='#999'
              indicatorActiveColor='#333'
              circular
              indicatorDots
              autoplay
            >

       { photoInfo
          ?
          photoInfo.map((Info,index)=>(
            <SwiperItem key={index}>
              <View className='swiperWrapping'>
                <Image className='siwperImage' src={'data:image/png;base64,'+Info.photo} />
              </View>
            </SwiperItem>))
            :
            null
      }
      </Swiper>
    </View>
      
    )
   
}
